import { showLoading, hideLoading } from "@/utils/message";

let loadingRequestCount = 0;

const openLoading = () => {
    if (loadingRequestCount === 0) {
        showLoading("加载中...");
    }
    loadingRequestCount++;
};

const closeLoading = () => {
    if (loadingRequestCount <= 0) return;
    loadingRequestCount--;
    if (loadingRequestCount === 0) {
        hideLoading();
    }
};

export { openLoading, closeLoading };
